package com.ibeeking.found.cop.b.rest.controller.v1;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ibeeking.found.cop.b.rest.service.IMsgMessageSopService;
import com.ibeeking.found.cop.service.common.param.MsgMessageSopParam;
import com.ibeeking.found.cop.service.common.query.MsgMessageSopPageQuery;
import com.ibeeking.found.cop.service.common.query.MsgMessageSopQuery;
import com.ibeeking.found.cop.service.common.vo.MsgMessageSopVO;
import com.ibeeking.nematos.constants.enums.OperateLogTypeEnum;
import com.ibeeking.nematos.log.annotation.Log;
import com.ibeeking.nematos.utils.base.BaseValidationGroup;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName MsgMessageSopController
 * @Description
 * @Author ibeeking
 * @Date 2021-06-02 18:15
 **/
@RestController
@RequestMapping("/b/msgMessageSop/v1")
public class MsgMessageSopController {

    @Resource
    private IMsgMessageSopService msgMessageSopServiceImpl;

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "查询群发SOP任务列表")
    @PostMapping(value = "/list")
    public List<MsgMessageSopVO> list(@RequestBody MsgMessageSopQuery query) {
        return msgMessageSopServiceImpl.list(query);
    }

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "查询群发SOP任务分页列表")
    @PostMapping(value = "/pageList")
    public Page<MsgMessageSopVO> pageList(@RequestBody MsgMessageSopPageQuery pageQuery) {
        return msgMessageSopServiceImpl.pageList(pageQuery);
    }

    @Log(logType = OperateLogTypeEnum.SAVE, describe = "添加群发SOP任务")
    @PostMapping(value = "/add")
    public Boolean add(@RequestBody @Validated(BaseValidationGroup.Insert.class) MsgMessageSopParam param) {
        return msgMessageSopServiceImpl.add(param);
    }

    @Log(logType = OperateLogTypeEnum.MODIFY, describe = "修改群发SOP任务")
    @PostMapping(value = "/modify")
    public Boolean modify(@RequestBody @Validated(BaseValidationGroup.Update.class) MsgMessageSopParam param) {
        return msgMessageSopServiceImpl.modify(param);
    }

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "查看群发SOP任务详情")
    @GetMapping(value = "/view/{id}")
    public MsgMessageSopVO view(@PathVariable("id") Long id) {
        return msgMessageSopServiceImpl.view(id);
    }

    @Log(logType = OperateLogTypeEnum.DEL, describe = "删除群发SOP任务")
    @GetMapping(value = "/del/{id}")
    public Boolean del(@PathVariable("id") Long id) {
        return msgMessageSopServiceImpl.del(id);
    }

}
